package practise.alogrithm.hundredInterviewQuestions.secondTime;

import practise.alogrithm.hundredInterviewQuestions.Utils.TreeBuilder;
import practise.alogrithm.hundredInterviewQuestions.Utils.TreeNode;

/**
 * Created by Richard on 7/26/2014.
 */
public class TreeDepth {
    public Integer get(TreeNode treeNode){
        if(treeNode==null){
            return 0;
        }
        return Math.max(get(treeNode.getLeft()),get(treeNode.getRight()))+1;
    }

    public static void main(String[] args){
        System.out.print("depth:"+new TreeDepth().get(TreeBuilder.createTreeByArrayInWidth(new int[]{1,2,3,4,5,6,7,8})));
    }
}
